
//------------------------------------------------------------------------------

using Apps.Models;
using Apps.IDAL.CY;
using System;
using System.Linq;

namespace Apps.DAL.CY
{
	public partial class CY_OUTSTOCKRepository:BaseRepository<CY_OUTSTOCK>,ICY_OUTSTOCKRepository,IDisposable
	{
	    public CY_OUTSTOCKRepository(DBContainer db):base(db)
        {
        
        }

        public IQueryable<CY_OUTSTOCKModel> QueryOutStockList()
        {
            IQueryable<CY_OUTSTOCKModel> list = from a in Context.CY_OUTSTOCK
                                                join b in Context.PUB_TEAM on a.TEAM_ID equals b.TEAM_ID into team
                                                from tb in team.DefaultIfEmpty()
                                                join c in Context.SysUser on a.OUTSTOCK_USER equals c.UserName into tuser
                                                from tc in tuser.DefaultIfEmpty()
                                                select new CY_OUTSTOCKModel()
                                                {
                                                    COALYARD_AMOUNT = a.COALYARD_AMOUNT,
                                                    OUTSTOCK_DATE = a.OUTSTOCK_DATE,
                                                    OUTSTOCK_ID = a.OUTSTOCK_ID,
                                                    OUTSTOCK_TIME = a.OUTSTOCK_TIME,
                                                    TEAM_ID = a.TEAM_ID,
                                                    OUTSTOCK_USER = a.OUTSTOCK_USER,
                                                    START_AMOUNT = a.START_AMOUNT,
                                                    TEAM_NAME = tb.TEAM_NAME,
                                                    TOTAL = a.TOTAL,
                                                    OUTSTOCK_USER_Name=tc.TrueName
                                                };
            return list;
        }
    }
}
